package org.phoenixframework.oauth2.server.config.exception;

import org.phoenixframework.common.tools.ResultModel;
import org.springframework.security.oauth2.common.exceptions.OAuth2Exception;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * Created by IntelliJ IDEA.
 *
 * @author doublelifeke
 * Email: hautxxxyzjk@163.com
 * DateTime: 2021/6/13 18:15
 * Description: 全局处理抛出的异常
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = OAuth2Exception.class)
    public ResultModel<?> handleOauth2(OAuth2Exception e) {
        return ResultModel.error(e.getMessage());
    }
}
